import { handleSearchLoading, handleSearchTime } from "@userList/search";
import { searchList } from "./store";
import { refreshTable } from ".";
const searchLoading = ref(false);
const resetLoading = ref(false);
export const searchConfig = () => {
  const defineSearch = {
    okText: getProxyT("base.query"),
    cancelText: getProxyT("base.reset"),
    searchLoading,
    resetLoading,
    refreshTableData: async (searchParams: any, type: any) => {
      handleSearchTime(
        ["create_time_start", "create_time_end"],
        searchParams,
        "YYYY-MM-DD HH:mm",
        "create_time"
      );
      handleSearchTime(
        ["update_time_start", "update_time_end"],
        searchParams,
        "YYYY-MM-DD HH:mm",
        "operate_time"
      );
      searchParams.support_pay =
        +searchParams.support_pay === Infinity
          ? undefined
          : searchParams.support_pay;
      searchParams.pay_type =
        +searchParams.pay_type === Infinity ? undefined : searchParams.pay_type;
      searchParams.status =
        +searchParams.status === Infinity ? undefined : searchParams.status;
      handleSearchLoading(true, type, defineSearch);
      await refreshTable(searchParams);
      handleSearchLoading(false, type, defineSearch);
    },
    searchList,
  };
  return defineSearch;
};
